﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AMail.Common.Interfaces.Data;

namespace AMail.Modules.Data.Actions
{
  public class MoveMessagesAction : IMailAction
  {
    private List<IMailMessage> messagesMoved;
    private IMailFolder previousParentFolder;

    public MoveMessagesAction(IEnumerable<IMailMessage> messages, IMailFolder previousParentFolder)
    {
      this.messagesMoved = messages.ToList();
      this.previousParentFolder = previousParentFolder;
    }

    #region IMailAction Members

    public void Commit(IMailArchiver archiver)
    {
    }

    public void Undo()
    {
      foreach (var message in messagesMoved)
        message.ParentFolder = this.previousParentFolder;
    }

    #endregion
  }
}
